package com.hontech.bread.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bread.R
import com.hontech.bread.device.deliveryDelivery
import com.hontech.bread.device.deliveryLeft
import com.hontech.bread.device.deliveryRight
import com.hontech.bread.ui.dialog.runProg
import com.hontech.bread.utils.onClick
import com.hontech.bread.utils.stringById

class DeliveryMotorParts(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_delivery_motor, this)
        val left = view.findViewById<Button>(R.id.id_delivery_left)
        val right = view.findViewById<Button>(R.id.id_delivery_right)
        val delivery = view.findViewById<Button>(R.id.id_delivery_btn_delivery)

        left.onClick {
            runProg(stringById(R.string.t1733460848_402), stringById(R.string.t1733460848_403)) {
                deliveryLeft()
            }
        }
        right.onClick {
            runProg(stringById(R.string.t1733460848_404), stringById(R.string.t1733460848_405)) {
                deliveryRight()
            }
        }
        delivery.onClick {
            runProg(stringById(R.string.t1733460848_406), stringById(R.string.t1733460848_407)) {
                deliveryDelivery()
            }
        }
    }
}
